# --*-- coding: utf-8 --*--

"""
Author: Darker
Description: 类单例模式
Version: 0.0.1
LastUpdateDate: 2021-07-13
UpdateURL:
LOG:
"""


class Singleton(object):
	"""
		单例模式（装饰类的类装饰器）
	"""

	instances = {}

	def __init__(self, cls: type):
		self.cls = cls
		self.cls_name = cls.__name__

	def __call__(self, *args, **kwargs):
		if self.cls_name not in __class__.instances:
			__class__.instances[self.cls_name] = self.cls(*args, **kwargs)
		return __class__.instances[self.cls_name]
